import os
import shutil

path = "./"
files = os.listdir(path)

for f in files:
    # 文件夹不存在，然后创建文件夹，并移动文件
    folder_name = path+f.split('.')[-1]
    if not os.path.exists(folder_name):
        os.mkdir(folder_name)
        shutil.move(f,folder_name)
    else:
        shutil.move(f,folder_name)
